/*   1:    */ package tt.dz.web.controller.user;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import java.util.ArrayList;
/*   5:    */ import java.util.HashMap;
/*   6:    */ import java.util.Iterator;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.annotation.Resource;
/*  10:    */ import javax.servlet.http.HttpServletRequest;
/*  11:    */ import javax.servlet.http.HttpServletResponse;
/*  12:    */ import org.apache.commons.collections.CollectionUtils;
/*  13:    */ import org.springframework.stereotype.Controller;
/*  14:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  15:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  16:    */ import tt.dz.biz.service.user.SystemInfoService;
/*  17:    */ import tt.dz.common.LogUtil;
/*  18:    */ import tt.dz.vo.ResponseModle;
/*  19:    */ import tt.dz.vo.SystemInfoVO;
/*  20:    */ import tt.dz.web.controller.BaseController;
/*  21:    */ 
/*  22:    */ @Controller
/*  23:    */ public class SystemInfoController
/*  24:    */   extends BaseController
/*  25:    */ {
/*  26:    */   @Resource(name="systemInfoService")
/*  27:    */   private SystemInfoService systemInfoService;
/*  28:    */   
/*  29:    */   @RequestMapping(value={"/listAllSystemInfo"}, produces={"application/json;charset=UTF-8"})
/*  30:    */   @ResponseBody
/*  31:    */   public String listAllSystemInfo()
/*  32:    */   {
/*  33: 37 */     ResponseModle responseModle = null;
/*  34:    */     try
/*  35:    */     {
/*  36: 39 */       List<SystemInfoVO> systemInfoList = this.systemInfoService.listAllSystemInfo();
/*  37: 40 */       responseModle = new ResponseModle("success", systemInfoList);
/*  38:    */     }
/*  39:    */     catch (Exception e)
/*  40:    */     {
/*  41: 42 */       LogUtil.error("查询业务系统对象异常", e);
/*  42: 43 */       responseModle = new ResponseModle("error", new ArrayList());
/*  43:    */     }
/*  44: 45 */     return JSON.toJSONString(responseModle);
/*  45:    */   }
/*  46:    */   
/*  47:    */   @RequestMapping(value={"/mapAllSystemInfo"}, produces={"application/json;charset=UTF-8"})
/*  48:    */   @ResponseBody
/*  49:    */   public String mapAllSystemInfo()
/*  50:    */   {
/*  51: 55 */     ResponseModle responseModle = null;
/*  52:    */     try
/*  53:    */     {
/*  54: 57 */       List<SystemInfoVO> systemInfoList = this.systemInfoService.listAllSystemInfo();
/*  55: 58 */       Iterator<SystemInfoVO> iterator = systemInfoList.iterator();
/*  56: 59 */       SystemInfoVO systemInfoVO = null;
/*  57: 60 */       Map<String, SystemInfoVO> systemInfoMap = new HashMap();
/*  58: 61 */       while (iterator.hasNext())
/*  59:    */       {
/*  60: 62 */         systemInfoVO = (SystemInfoVO)iterator.next();
/*  61: 63 */         systemInfoMap.put(systemInfoVO.getSysCode(), systemInfoVO);
/*  62:    */       }
/*  63: 65 */       responseModle = new ResponseModle("success", systemInfoMap);
/*  64:    */     }
/*  65:    */     catch (Exception e)
/*  66:    */     {
/*  67: 67 */       LogUtil.error("查询业务系统对象异常", e);
/*  68: 68 */       responseModle = new ResponseModle("error", new HashMap());
/*  69:    */     }
/*  70: 70 */     return JSON.toJSONString(responseModle);
/*  71:    */   }
/*  72:    */   
/*  73:    */   @RequestMapping(value={"/listAllValidSystemInfo"}, produces={"application/json;charset=UTF-8"})
/*  74:    */   @ResponseBody
/*  75:    */   public String listAllValidSystemInfo()
/*  76:    */   {
/*  77: 80 */     ResponseModle responseModle = null;
/*  78:    */     try
/*  79:    */     {
/*  80: 82 */       List<SystemInfoVO> systemInfoList = this.systemInfoService.listAllValidSystemInfo();
/*  81: 83 */       responseModle = new ResponseModle("success", systemInfoList);
/*  82:    */     }
/*  83:    */     catch (Exception e)
/*  84:    */     {
/*  85: 85 */       LogUtil.error("查询业务系统对象异常", e);
/*  86: 86 */       responseModle = new ResponseModle("error", new ArrayList());
/*  87:    */     }
/*  88: 88 */     return JSON.toJSONString(responseModle);
/*  89:    */   }
/*  90:    */   
/*  91:    */   @RequestMapping(value={"/modifySystemInfo"}, produces={"application/json;charset=UTF-8"})
/*  92:    */   @ResponseBody
/*  93:    */   public String modifySystemInfo(HttpServletRequest request, HttpServletResponse response)
/*  94:    */   {
/*  95:100 */     boolean excuteFlag = false;
/*  96:    */     try
/*  97:    */     {
/*  98:102 */       String modifyType = request.getParameter("modifyType");
/*  99:103 */       SystemInfoVO systemInfoVO = (SystemInfoVO)JSON.parseObject(request.getParameter("systemInfoVO"), SystemInfoVO.class);
/* 100:104 */       List<SystemInfoVO> existsList = this.systemInfoService.listAllSystemInfo();
/* 101:105 */       if ("insert".equals(modifyType))
/* 102:    */       {
/* 103:106 */         if (CollectionUtils.isNotEmpty(existsList)) {
/* 104:107 */           for (SystemInfoVO vo : existsList) {
/* 105:108 */             if (vo.getSysCode().equals(systemInfoVO.getSysCode())) {
/* 106:109 */               return JSON.toJSONString(assemblyResponseData(false, "系统编码已存在，请重新输入系统编码。"));
/* 107:    */             }
/* 108:    */           }
/* 109:    */         }
/* 110:113 */         excuteFlag = this.systemInfoService.insertSystemInfo(systemInfoVO);
/* 111:    */       }
/* 112:114 */       else if ("update".equals(modifyType))
/* 113:    */       {
/* 114:115 */         excuteFlag = this.systemInfoService.updateSystemInfo(systemInfoVO);
/* 115:    */       }
/* 116:    */     }
/* 117:    */     catch (Exception e)
/* 118:    */     {
/* 119:118 */       LogUtil.error("更改业务系统对象异常", e);
/* 120:119 */       excuteFlag = false;
/* 121:    */     }
/* 122:121 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, "操作失败，请稍后再试。"));
/* 123:    */   }
/* 124:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.user.SystemInfoController
 * JD-Core Version:    0.7.0.1
 */